#include <iostream>
#include <fstream>
#include <string>
using namespace std;

#define READ_FILE

string untwist(int key, const string& ciphertext);
int getCode(char ch);
char getChar(int code);

int main()
{
#ifdef READ_FILE
    ifstream readIn("1006.input");
	if (!readIn)
	{
		readIn.open("../1006.input");
	}
#else
#define readIn cin
#endif

    int key;
    string plaintext;
    string ciphertext;

    while (true)
    {
        readIn >> key;
        if (key == 0)
        {
            break;
        }
        readIn >> ciphertext;
        plaintext = untwist(key, ciphertext);
        cout << plaintext << endl;
    }

#ifdef READ_FILE
    readIn.close();
#endif
}

int getCode(char ch)
{
    if (ch == '_')
    {
        return 0;
    }
    if (ch == '.')
    {
        return 27;
    }

    return (int) (ch - 'a' + 1);
}

char getChar(int code)
{
    if (code == 0)
    {
        return '_';
    }
    if (code == 27)
    {
        return '.';
    }

    return (char) (code - 1 + 'a');
}

string untwist(int key, const string& ciphertext)
{
    int n = ciphertext.length();

    string plaintext(ciphertext);
    int ciphercode, plaincode, plainindex;

    for (int i = 0; i < n; i++)
    {
        ciphercode = getCode(ciphertext[i]);
        plainindex = key * i % n;
        plaincode = (ciphercode + i) % 28;
        plaintext[plainindex] = getChar(plaincode);
    }


    return plaintext;
}

